package org.wpahs.ahn.rssfeed;

import android.content.ContentValues;
import android.os.Parcel;
import android.os.Parcelable;

import java.io.Serializable;
import java.util.Date;

/**
 * Created by dgambone on 01/05/2015.
 */
public class MyFeed  {
    private String title = "";
    private String subtitle = "";
    private String url = "";
    private int id = 0;
    private Date lastUpdated = null;
    private String image = null;


    public String getTitle() {
        if(title == null || title.length() == 0){
            return getUrl();
        }
        return title;
    }

    public void setTitle(String title) {
        if(title == null)return;
        this.title = title;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getSubtitle() {
        return subtitle;
    }

    public void setSubtitle(String subtitle) {
        if(subtitle == null)return;

        this.subtitle = subtitle;
    }

    public Date getLastUpdated() {
        return lastUpdated;
    }

    public String getLastUpdatedToString() {
        if(lastUpdated == null){
            return  "";
        }else {
            return String.valueOf(lastUpdated.getTime());
        }
    }

    public void setLastUpdateFromString(String milisecs) {
        if(milisecs != null){
            if(!milisecs.equals("")){
                lastUpdated = new Date(Long.parseLong(milisecs));
            }else{
                lastUpdated = null;
            }
        }else {
            lastUpdated = null;
        }
    }

    public void setLastUpdated(Date lastUpdated) {
        this.lastUpdated = lastUpdated;
    }



    @Override
    public String toString() {
        return getTitle();
    }


    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getImage() {
        return image;
    }

    public void setImage(String image) {
        this.image = image;
    }
}
